home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.4)
-
- import formatter
- import htmllib
- import unittest
- from test import test_support
-
- class AnchorCollector(htmllib.HTMLParser):
-
- def __init__(self, *args, **kw):
- self._AnchorCollector__anchors = []
- htmllib.HTMLParser.__init__(self, *args, **kw)
-
-
- def get_anchor_info(self):
- return self._AnchorCollector__anchors
-
-
- def anchor_bgn(self, *args):
- self._AnchorCollector__anchors.append(args)
-
-
-
- class DeclCollector(htmllib.HTMLParser):
-
- def __init__(self, *args, **kw):
- self._DeclCollector__decls = []
- htmllib.HTMLParser.__init__(self, *args, **kw)
-
-
- def get_decl_info(self):
- return self._DeclCollector__decls
-
-
- def unknown_decl(self, data):
- self._DeclCollector__decls.append(data)
-
-
-
- class HTMLParserTestCase(unittest.TestCase):
-
- def test_anchor_collection(self):
- parser = AnchorCollector(formatter.NullFormatter(), verbose = 1)
- parser.feed("<a href='http://foo.org/' name='splat'> </a>\n <a href='http://www.python.org/'> </a>\n <a name='frob'> </a>\n ")
- parser.close()
- self.assertEquals(parser.get_anchor_info(), [
- ('http://foo.org/', 'splat', ''),
- ('http://www.python.org/', '', ''),
- ('', 'frob', '')])
-
-
- def test_decl_collection(self):
- parser = DeclCollector(formatter.NullFormatter(), verbose = 1)
- parser.feed('<html>\n <body>\n hallo\n <![if !supportEmptyParas]> <![endif]>\n </body>\n </html>\n ')
- parser.close()
- self.assertEquals(parser.get_decl_info(), [
- 'if !supportEmptyParas',
- 'endif'])
-
-
-
- def test_main():
- test_support.run_unittest(HTMLParserTestCase)
-
- if __name__ == '__main__':
- test_main()
-
-